(function($) {

	function onSuccess(data,state,xhr) {
		if(xhr.status === 0) {
			flash('error', 'no response code');
			return;
		}
		epic.flash('info', 'success');
		$.makeArray(arguments).each(function(i,a) { if (console) {console.log(a); console.log(i); } } );
	}

	// try to remove spinner
	function onComplete() {
		if(this.button) {
			this.button.mojo.deactivate();
		}
	}

	function onError(xhr,state) {
		epic.flash('error', 'status code: ' + xhr.status);
		$.makeArray(arguments).each(function(i,a) { if (console) {console.log(a); console.log(i); } } );
	}

	// gobal ajax setup
	function ajax(params) {
		var defaults = {
			timeout: 3000,
			cache: false,
			error: onError,
			success: onSuccess,
			complete: onComplete
		};
		var opts = $.extend({}, defaults, params);
		$.ajax(opts);
	}
	epic.ajax = ajax;

})(jQuery);
